package com.shendu.task.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.shendu.task.domain.RetVo;
import com.shendu.task.domain.TaskDoc;
import com.shendu.task.domain.TaskList;
import com.shendu.task.service.TaskService;

@RestController
@RequestMapping("/task")  
public class TaskController {
	@Autowired
	private TaskService taskService;
	/**
	 * 同步任务
	 * @param task
	 */
	@RequestMapping("/synTask")  
	public void synTask(@RequestBody TaskList tasks) {
		taskService.synTask(tasks.getTasks());
	}
	/**
	 * 更新任务 
	 * @param taskId
	 * @param task
	 */
	@RequestMapping("/update/{taskId}")  
	public void updateTask(@PathVariable String taskId,TaskDoc task) {
		taskService.updateTask(task);
	}
	/**
	 * 按照用户查找用户
	 * @param task
	 * @return 
	 */
	@RequestMapping("/list/{userId}")  
	public RetVo listByUserId(@PathVariable String userId,TaskDoc task) {
		task.setUserId(userId);
		List<TaskDoc> list = taskService.list(task);
		return new RetVo(list);
	}
}
